home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 5
/
Gekikoh Dennoh Club Vol. 5 (Japan).7z
/
Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin
/
internet
/
webx
/
pws010.lzh
/
PersonalWS.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-11
|
4KB
|
173 lines
/* PersonelWS.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dos.h>
#define MY_USER_STACK 48*1024
#define MY_SUPER_STACK 32*1024
extern int ReceiveMessage (int );
extern int SendCommand (int , char *);
extern int OpenSock(char *, int );
extern int OpenPassiveSock (int port);
extern int ServerInit(void);
extern int ServerMain(void);
extern int ServerTini(void);
extern void CloseSock(int );
/* ï⌠ÉöâAâhâîâXé╔É«ìçé╖éΘé╜é▀é╔éφé┤éφé┤ short é┼ÉΘî╛é╡é─éóéΘ */
/* char é╞é⌐é┼ÉΘî╛é╖éΘé╞âXâ^âbâNé╠ÆΩé¬è∩ÉöâAâhâîâXé╔É▌ÆΦé│éΩé╜éΦé│éΩé╚é⌐é┴é╜éΦ */
short user_stack[MY_USER_STACK / 2];
short super_stack[MY_SUPER_STACK / 2];
char *id_str = "PersonalWS"; /* ÅφÆôÄ»ò╩ùpò╢ÄÜù± */
struct _prcctrl buff;
char *base_dir = ".";
char *quit_str = "QUIT";
int v_option = 0;
/* âXâ^âbâNâTâCâYé╞âqü[âvâTâCâYé≡ÄwÆΦ */
int _stacksize = 32 * 1024;
int _heapsize = 256 * 1024;
void usage (void)
{
printf ("âpü[â\âiâïâEâFâuâTü[âoü[ PersonalWS.x ver0.10\n"
" programmed by Mitsuky <FreeSoftware>\n"
"âEâFâuâTü[âoü[é┼é╖\n"
"Ägùpû@ : PersonalWS [option] [âxü[âXâfâBâîâNâgâè]\n"
"[option]\n"
" -V : Å┌ì╫ò\Īâéü[âh\n"
" -Qò╢ÄÜù± : ÅIù╣ò╢ÄÜù±üiû│ÄwÆΦÄ₧é═ QUIT üj\n"
" -R : ÅφÆôë≡Å£\n"
"âxü[âXâfâBâîâNâgâèé≡Å╚ù¬é╖éΘé╞âJâîâôâgâfâBâîâNâgâèé≡âxü[âXé╞é╡é▄é╖\n"
"éaéfâvâìâZâXé┼ô«ì∞é╖éΘé╠é┼ Human68K ver.2 ê╚ì~üA\n"
"é⌐é┬ CONFIG.SYS é┼ PROCESS = é╠É▌ÆΦé≡é╖éΘòKùvé¬éáéΦé▄é╖\n"
);
}
/* ÅφÆôòö */
void keepent (void)
{
for (;;) {
if (buff.your_id != 0xffff) {
/* âXâîâbâhè╘Æ╩ÉMé¬éáé┴é╜ÅΩìç */
int th_command;
th_command = buff.command;
buff.your_id = 0xffff; /* æùéΦÄΦé╠âXâîâbâhéhécé≡ -1 é╔ */
if (th_command == 0xfff9) { /* Ä⌐ÄEâRâ}âôâhüH */
ServerTini();
_dos_kill_pr ();
}
} else {
/* âXâîâbâhè╘Æ╩ÉMé¬é╚é⌐é┴é╜ÅΩìç */
if (ServerMain()<0){
ServerTini();
_dos_kill_pr ();
}
_dos_change_pr();
}
}
}
int main (int argc, char *argv[])
{
int i;
int slash_flag = 0;
struct _prcptr prc;
int my_id, your_id;
int r_option = 0;
{
char *temp;
temp = getenv ("SLASH");
if ((temp != NULL) && (*temp == '/')) {
slash_flag = 1;
}
}
for (i = 1; i < argc; i++) {
if (('-' == *argv[i]) || ((slash_flag == 0) && ('/' == *argv[i]))) {
switch (*(argv[i] + 1)) {
case 'r':
case 'R':
r_option = !0;
break;
case 'v':
case 'V':
v_option = !0;
break;
case 'q':
case 'Q':
quit_str=argv[i]+2;
break;
default:
usage ();
return (-1);
}
} else {
base_dir = argv[i];
}
}
my_id = _dos_get_pr (-2, &prc);
strcpy (prc.name, id_str);
if ((your_id = _dos_get_pr (-1, &prc)) < 0) {
if (!r_option) {
/* ÅφÆôé╡é─éóé╚éóÅΩìçé═ÅφÆô */
struct _psp *my_psp;
void *mem_top,*mem_last;
if (ServerInit())
return(-1);
printf ("ÅφÆôé╡é▄é╖\n");
buff.length = 0;
buff.command = 0xffff;
buff.your_id = -1;
_dos_open_pr (id_str, 2, (int) &user_stack[MY_USER_STACK / 2], (int) &super_stack[MY_SUPER_STACK / 2], 0, (int) &keepent, &buff, 1);
my_psp = _dos_getpdb ();
mem_top = (int *) ((int)my_psp - 0x10);
mem_last = (int *)(*(int *)((int)mem_top + 0x08));
_dos_keeppr ((int)mem_last-(int)mem_top - (0x10 + 0xf0), 0);
} else {
printf ("é▄é╛ÅφÆôé╡é─éóé▄é╣é±\n");
return (-1);
}
} else {
if (r_option) {
#if 0
/* è∙é╔ÅφÆôé╡é─éóé╜ÅΩìçé═Ä⌐ÄEâRâ}âôâhé≡æùéΘ */
ServerTini();
while (_dos_send_pr (my_id, your_id, 0xfff9, NULL, 0) == -28)
_dos_change_pr ();
#endif
int temp_sock;
char temp_str[256];
temp_sock = OpenSock("localhost",80);
sprintf (temp_str, "GET /%s HTTP/1.0\r\n\r\n",quit_str);
SendCommand(temp_sock,temp_str);
ReceiveMessage(temp_sock);
CloseSock(temp_sock);
printf ("ÅφÆôë≡Å£é╡é▄é╡é╜\n");
} else {
printf ("è∙é╔ÅφÆôé╡é─éóé▄é╖\n");
return (-1);
}
}
return (0);
}